import random
def binaryCheck(n):
    """ 二分法，关键 """
    start, end = 1,n
    while start < end:
        mid = start + (end-start)>>2 # 防溢出，位运算更快
        if check(mid):
            end = mid 
        else:
            start = mid + 1
    return start 

def check(n):
    return random.randint(1,n) == n

print(binaryCheck(4))